package easy;

public class Solution_2078 {

    public int maxDistance(int[] colors) {
        int[] array = new int[colors.length];
        for (int i = 1; i < colors.length; i++) {
            for (int j = 0; j < i; j++) {
                if (colors[j] != colors[i]) {
                    array[i] = i - j;
                    break;
                }
            }
        }
        int max = 0;
        for (int num : array) {
            if (num > max) {
                max = num;
            }
        }
        return max;
    }

    public static void main(String[] args) {
        Solution_2078 model = new Solution_2078();
        System.out.println(model.maxDistance(new int[]{1, 1, 1, 6, 1, 1, 1}));
        System.out.println(model.maxDistance(new int[]{1, 8, 3, 8, 3}));
        System.out.println(model.maxDistance(new int[]{0, 1}));
    }
}
